bitkeeper revision 1.1159.212.95 (4204aa0ee0re5Xx1zWrJ9ejxzgRs3w)
authorkaf24@scramble.cl.cam.ac.uk <kaf24@scramble.cl.cam.ac.uk>
Sat, 5 Feb 2005 11:12:14 +0000 (11:12 +0000)
committerkaf24@scramble.cl.cam.ac.uk <kaf24@scramble.cl.cam.ac.uk>
Sat, 5 Feb 2005 11:12:14 +0000 (11:12 +0000)
Various cleanups. Remove PDB pending simpler GDB stub and/or NetBSD debugger.
Force emacs mode to appropriate tabbing in various files.
Signed-off-by: keir.fraser@cl.cam.ac.uk
41 files changed:
.rootkeys
xen/Rules.mk
xen/arch/x86/Makefile
xen/arch/x86/dom0_ops.c
xen/arch/x86/pdb-linux.c [deleted file]
xen/arch/x86/pdb-stub.c [deleted file]
xen/arch/x86/setup.c
xen/arch/x86/shadow.c
xen/arch/x86/time.c
xen/common/Makefile
xen/common/ac_timer.c
xen/common/debug-linux.c [deleted file]
xen/common/debug.c [deleted file]
xen/common/dom0_ops.c
xen/common/dom_mem_ops.c
xen/common/domain.c
xen/common/elf.c
xen/common/event_channel.c
xen/common/grant_table.c
xen/common/kernel.c
xen/common/keyhandler.c
xen/common/lib.c
xen/common/multicall.c
xen/common/page_alloc.c
xen/common/perfc.c
xen/common/physdev.c
xen/common/resource.c
xen/common/sched_atropos.c
xen/common/sched_bvt.c
xen/common/sched_rrobin.c
xen/common/schedule.c
xen/common/softirq.c
xen/common/string.c
xen/common/trace.c
xen/common/vsprintf.c
xen/common/xmalloc.c
xen/drivers/char/console.c
xen/drivers/char/serial.c
xen/include/asm-x86/pdb.h [deleted file]
xen/include/asm-x86/processor.h
xen/include/asm-x86/vmx_platform.h

index f30ef49ac8df2270e9f9d88f1d26aa2d34a0b9df..f93285fa18713c54817d855885faf9e85e111171 100644 (file)
--- a/.rootkeys
+++ b/.rootkeys
 3ddb79bcZ_2FxINljqNSkqa17ISyJw xen/arch/x86/pci-pc.c
 3ddb79bdeJ7_86z03yTAPIeeywOg3Q xen/arch/x86/pci-x86.c
 3ddb79bdIKgipvGoqExEQ7jawfVowA xen/arch/x86/pci-x86.h
-40a4dfced2dnSzbKgJFlD3chKHexjQ xen/arch/x86/pdb-linux.c
-4022a73czgX7d-2zfF_cb33oVemApQ xen/arch/x86/pdb-stub.c
 3ddb79bc7KxGCEJsgBnkDX7XjD_ZEQ xen/arch/x86/rwlock.c
 3ddb79bcrD6Z_rUvSDgrvjyb4846Eg xen/arch/x86/setup.c
 405b8599xI_PoEr3zZoJ2on-jdn7iw xen/arch/x86/shadow.c
 40e96d3akN3Hu_J5Bk-WXD8OGscrYQ xen/arch/x86/x86_64/xen.lds
 3ddb79bdff-gj-jFGKjOejeHLqL8Lg xen/common/Makefile
 3e397e66AyyD5fYraAySWuwi9uqSXg xen/common/ac_timer.c
-4022a73c_BbDFd2YJ_NQYVvKX5Oz7w xen/common/debug-linux.c
-3fa152581E5KhrAtqZef2Sr5NKTz4w xen/common/debug.c
 3ddb79bdLX_P6iB7ILiblRLWvebapg xen/common/dom0_ops.c
 3e6377e4i0c9GtKN65e99OtRbw3AZw xen/common/dom_mem_ops.c
 3ddb79bdYO5D8Av12NHqPeSviav7cg xen/common/domain.c
 41a61536MFhNalgbVmYGXAhQsPTZNw xen/include/asm-x86/multicall.h
 3ddb79c3xjYnrv5t3VqYlR4tNEOl4Q xen/include/asm-x86/page.h
 3ddb79c3ysKUbxZuwKBRK3WXU2TlEg xen/include/asm-x86/pci.h
-4022a73diKn2Ax4-R4gzk59lm1YdDg xen/include/asm-x86/pdb.h
 3ddb79c2QF5-pZGzuX4QukPCDAl59A xen/include/asm-x86/processor.h
 40cf1596bim9F9DNdV75klgRSZ6Y2A xen/include/asm-x86/regs.h
 3ddb79c2plf7ciNgoNjU-RsbUzawsw xen/include/asm-x86/rwlock.h
index 82599afec0056adbfadb93b40741f56b416b192f..186f4e3536939d11c9dffad5db6c0808c7323c29 100644 (file)
@@ -54,9 +54,9 @@ else
 CFLAGS += -DVERBOSE
 endif
 
-ifeq ($(debugger),y)
-CFLAGS += -DXEN_DEBUGGER
-endif
+#ifeq ($(debugger),y)
+#CFLAGS += -DXEN_DEBUGGER
+#endif
 
 ifeq ($(perfc),y)
 CFLAGS += -DPERF_COUNTERS
index 992d580fef0174c990438b947bfa8b97831c6f47..fe9a39df822916e59c7cccf3fe0aacddc5e1483a 100644 (file)
@@ -1,11 +1,6 @@
 
 include $(BASEDIR)/Rules.mk
 
-ifneq ($(debugger),y)
-OBJS := $(subst pdb-linux.o,,$(OBJS))
-OBJS := $(subst pdb-stub.o,,$(OBJS))
-endif
-
 OBJS += $(patsubst %.S,%.o,$(wildcard $(TARGET_SUBARCH)/*.S))
 OBJS += $(patsubst %.c,%.o,$(wildcard $(TARGET_SUBARCH)/*.c))
 OBJS += $(patsubst %.c,%.o,$(wildcard mtrr/*.c))
index c173d043a248f0c49f0df4b3557236ac08e8733c..8b06d8bc2cdee37bc0a67e054696acbd0f5999f9 100644 (file)
@@ -15,7 +15,6 @@
 #include <xen/event.h>
 #include <asm/domain_page.h>
 #include <asm/msr.h>
-#include <asm/pdb.h>
 #include <xen/trace.h>
 #include <xen/console.h>
 #include <asm/shadow.h>
diff --git a/xen/arch/x86/pdb-linux.c b/xen/arch/x86/pdb-linux.c
deleted file mode 100644 (file)
index cb4f0e0..0000000
+++ /dev/null
@@ -1,100 +0,0 @@
-
-/*
- * pervasive debugger
- * www.cl.cam.ac.uk/netos/pdb
- *
- * alex ho
- * 2004
- * university of cambridge computer laboratory
- *
- * linux & i386 dependent code. bleech.
- */
-
-#include <asm/pdb.h>
-
-/* offset to the first instruction in the linux system call code
-   where we can safely set a breakpoint */
-unsigned int pdb_linux_syscall_enter_bkpt_offset = 20;
-
-/* offset to eflags saved on the stack after an int 80 */
-unsigned int pdb_linux_syscall_eflags_offset     = 48;
-
-/* offset to the instruction pointer saved on the stack after an int 80 */
-unsigned int pdb_linux_syscall_eip_offset        = 40;
-
-unsigned char
-pdb_linux_set_bkpt (unsigned long addr)
-{
-    unsigned char old_instruction = *(unsigned char *)addr;
-    *(unsigned char *)addr = 0xcc;
-    return old_instruction;
-}
-
-void
-pdb_linux_clr_bkpt (unsigned long addr, unsigned char value)
-{
-    *(unsigned char *)addr = value;
-}
-
-void
-pdb_linux_syscall_enter_bkpt (struct xen_regs *regs, long error_code,
-                             trap_info_t *ti)
-{
-    /* set at breakpoint at the beginning of the 
-       system call in the target domain */
-    pdb_system_call_enter_instr = pdb_linux_set_bkpt(ti->address +
-                                   pdb_linux_syscall_enter_bkpt_offset);
-    pdb_system_call = 1;
-}
-
-void
-pdb_linux_syscall_exit_bkpt (struct xen_regs *regs, struct pdb_context *pdb_ctx)
-{
-    /*
-      we've hit an int 0x80 in a user's program, jumped into xen
-      (traps.c::do_general_protection()) which re-wrote the next
-      instruction in the os kernel to 0xcc, and then hit that 
-      exception.
-
-      we need to re-write the return instruction in the user's
-      program so that we know when we have finished the system call
-      and are back in the user's program.
-
-      at this point our stack should look something like this:
-
-      esp      = 0x80a59f0
-      esp + 4  = 0x0
-      esp + 8  = 0x80485a0
-      esp + 12 = 0x2d
-      esp + 16 = 0x80485f4
-      esp + 20 = 0xbffffa48
-      esp + 24 = 0xd
-      esp + 28 = 0xc00a0833
-      esp + 32 = 0x833
-      esp + 36 = 0xd
-      esp + 40 = 0x804dcdd     saved eip
-      esp + 44 = 0x82b         saved cs
-      esp + 48 = 0x213392      saved eflags
-      esp + 52 = 0xbffffa2c    saved esp
-      esp + 56 = 0x833         saved ss
-      esp + 60 = 0x1000000
-    */
-
-    /* restore the entry instruction for the system call */
-    pdb_linux_clr_bkpt(regs->eip - 1, pdb_system_call_enter_instr);
-
-    /* save the address of eflags that was saved on the stack */
-    pdb_system_call_eflags_addr = (regs->esp +
-                                  pdb_linux_syscall_eflags_offset);
-    /* muck with the return instruction so that we trap back into the
-       debugger when re-entering user space */
-    pdb_system_call_next_addr = *(unsigned long *)(regs->esp + 
-                                                pdb_linux_syscall_eip_offset);
-    pdb_linux_get_values (&pdb_system_call_leave_instr, 1, 
-                         pdb_system_call_next_addr,
-                         pdb_ctx->process, pdb_ctx->ptbr);
-    pdb_linux_set_values ("cc", 1, pdb_system_call_next_addr,
-                         pdb_ctx->process, pdb_ctx->ptbr);
-}
diff --git a/xen/arch/x86/pdb-stub.c b/xen/arch/x86/pdb-stub.c
deleted file mode 100644 (file)
index 568bcea..0000000
+++ /dev/null
@@ -1,1280 +0,0 @@
-
-/*
- * pervasive debugger
- * www.cl.cam.ac.uk/netos/pdb
- *
- * alex ho
- * 2004
- * university of cambridge computer laboratory
- *
- * code adapted originally from kgdb, nemesis, & gdbserver
- */
-
-#include <xen/lib.h>
-#include <xen/sched.h>
-#include <asm/regs.h>
-#include <xen/keyhandler.h> 
-#include <asm/apic.h>
-#include <asm/domain_page.h>                           /* [un]map_domain_mem */
-#include <asm/processor.h>
-#include <asm/pdb.h>
-#include <xen/list.h>
-#include <xen/serial.h>
-#include <xen/softirq.h>
-#include <xen/init.h>
-
-/* opt_pdb: Name of serial port for Xen pervasive debugger (and enable pdb) */
-static unsigned char opt_pdb[10] = "none";
-string_param("pdb", opt_pdb);
-
-#define PDB_DEBUG_TRACE
-#ifdef PDB_DEBUG_TRACE
-#define TRC(_x) _x
-#else
-#define TRC(_x)
-#endif
-
-#define DEBUG_EXCEPTION     0x01
-#define BREAKPT_EXCEPTION   0x03
-#define PDB_LIVE_EXCEPTION  0x58
-#define KEYPRESS_EXCEPTION  0x88
-
-#define BUFMAX 400
-
-static const char hexchars[] = "0123456789abcdef";
-
-static int remote_debug;
-
-#define PDB_BUFMAX 1024
-static char pdb_in_buffer[PDB_BUFMAX];
-static char pdb_out_buffer[PDB_BUFMAX];
-static char pdb_buffer[PDB_BUFMAX];
-
-struct pdb_context pdb_ctx;
-int pdb_continue_thread = 0;
-int pdb_general_thread = 0;
-
-void pdb_put_packet (unsigned char *buffer, int ack);
-void pdb_bkpt_check (u_char *buffer, int length,
-                    unsigned long cr3, unsigned long addr);
-
-int pdb_initialized = 0;
-int pdb_page_fault_possible = 0;
-int pdb_page_fault_scratch = 0;                     /* just a handy variable */
-int pdb_page_fault = 0;
-static int pdb_serhnd = -1;
-static int pdb_stepping = 0;
-
-int pdb_system_call = 0;
-unsigned char pdb_system_call_enter_instr = 0;       /* original enter instr */
-unsigned char pdb_system_call_leave_instr = 0;        /* original next instr */
-unsigned long pdb_system_call_next_addr = 0;         /* instr after int 0x80 */
-unsigned long pdb_system_call_eflags_addr = 0;      /* saved eflags on stack */
-
-static inline void pdb_put_char(unsigned char c)
-{
-    serial_putc(pdb_serhnd, c);
-}
-
-static inline unsigned char pdb_get_char(void)
-{
-    return serial_getc(pdb_serhnd);
-}
-
-int
-get_char (char *addr)
-{
-    return *addr;
-}
-
-void
-set_char (char *addr, int val)
-{
-    *addr = val;
-}
-
-void
-pdb_process_query (char *ptr)
-{
-    if (strcmp(ptr, "C") == 0)
-    {
-        /* empty string */
-    }
-    else if (strcmp(ptr, "fThreadInfo") == 0)
-    {
-#ifdef PDB_PAST
-        struct domain *p;
-#endif /* PDB_PAST */
-
-        int buf_idx = 0;
-
-       pdb_out_buffer[buf_idx++] = 'l';
-       pdb_out_buffer[buf_idx++] = 0;
-
-#ifdef PDB_PAST
-       switch (pdb_level)
-       {
-       case PDB_LVL_XEN:                        /* return a list of domains */
-       {
-           int count = 0;
-
-           read_lock(&domlist_lock);
-
-           pdb_out_buffer[buf_idx++] = 'm';
-           for_each_domain ( p )
-           {
-               domid_t domain = p->domain + PDB_ID_OFFSET;
-
-               if (count > 0)
-               {
-                   pdb_out_buffer[buf_idx++] = ',';
-               }
-               if (domain > 15)
-               {
-                   pdb_out_buffer[buf_idx++] = hexchars[domain >> 4];
-               }
-               pdb_out_buffer[buf_idx++] = hexchars[domain % 16];
-               count++;
-           }
-           pdb_out_buffer[buf_idx++] = 0;
-
-           read_unlock(&domlist_lock);
-           break;
-       }
-       case PDB_LVL_GUESTOS:                  /* return a list of processes */
-       {
-           int foobar[20];
-           int loop, total;
-
-                                                       /* this cr3 is wrong! */
-           total = pdb_linux_process_list(pdb_ctx[pdb_level].info_cr3,
-                                          foobar, 20);
-
-           pdb_out_buffer[buf_idx++] = 'm';     
-           pdb_out_buffer[buf_idx++] = '1';              /* 1 is to go back */
-           for (loop = 0; loop < total; loop++)
-           {
-               int pid = foobar[loop] + PDB_ID_OFFSET;
-
-               pdb_out_buffer[buf_idx++] = ',';
-               if (pid > 15)
-               {
-                   pdb_out_buffer[buf_idx++] = hexchars[pid >> 4];
-               }
-               pdb_out_buffer[buf_idx++] = hexchars[pid % 16];
-           }
-           pdb_out_buffer[buf_idx++] = 0;
-           break;
-       }
-       case PDB_LVL_PROCESS:                                     /* hmmm... */
-       {
-           pdb_out_buffer[buf_idx++] = 'm';
-           pdb_out_buffer[buf_idx++] = '1';              /* 1 is to go back */
-           break;
-       }
-       default:
-           break;
-       }
-#endif /* PDB_PAST */
-
-    }
-    else if (strcmp(ptr, "sThreadInfo") == 0)
-    {
-        int buf_idx = 0;
-
-       pdb_out_buffer[buf_idx++] = 'l';
-       pdb_out_buffer[buf_idx++] = 0;
-    }
-    else if (strncmp(ptr, "ThreadExtraInfo,", 16) == 0)
-    {
-        int thread = 0;
-       char *message = "foobar ?";
-
-       ptr += 16;
-        if (hexToInt (&ptr, &thread))
-       {
-            mem2hex (message, pdb_out_buffer, strlen(message) + 1);
-       }
-
-#ifdef PDB_PAST
-        int thread = 0;
-       char message[16];
-       struct domain *p;
-
-       strncpy (message, dom0->name, 16);
-
-       ptr += 16;
-        if (hexToInt (&ptr, &thread))
-       {
-            mem2hex ((char *)message, pdb_out_buffer, strlen(message) + 1);
-       }
-#endif /* PDB_PAST */
-
-#ifdef PDB_FUTURE
-      {
-       char string[task_struct_comm_length];
-
-       string[0] = 0;
-       pdb_linux_process_details (cr3, pid, string);
-       printk (" (%s)", string);
-      }
-#endif /* PDB_FUTURE*/
-
-    }
-    else if (strcmp(ptr, "Offsets") == 0)
-    {
-        /* empty string */
-    }
-    else if (strncmp(ptr, "Symbol", 6) == 0)
-    {
-        strcpy (pdb_out_buffer, "OK");
-    }
-    else
-    {
-        printk("pdb: error, unknown query [%s]\n", ptr);
-    }
-}
-
-void
-pdb_x86_to_gdb_regs (char *buffer, struct xen_regs *regs)
-{
-    int idx = 0;
-
-    mem2hex ((char *)&regs->eax, &buffer[idx], sizeof(regs->eax));
-    idx += sizeof(regs->eax) * 2;
-    mem2hex ((char *)&regs->ecx, &buffer[idx], sizeof(regs->ecx));
-    idx += sizeof(regs->ecx) * 2;
-    mem2hex ((char *)&regs->edx, &buffer[idx], sizeof(regs->edx));
-    idx += sizeof(regs->edx) * 2;
-    mem2hex ((char *)&regs->ebx, &buffer[idx], sizeof(regs->ebx));
-    idx += sizeof(regs->ebx) * 2;
-    mem2hex ((char *)&regs->esp, &buffer[idx], sizeof(regs->esp));
-    idx += sizeof(regs->esp) * 2;
-    mem2hex ((char *)&regs->ebp, &buffer[idx], sizeof(regs->ebp));
-    idx += sizeof(regs->ebp) * 2;
-    mem2hex ((char *)&regs->esi, &buffer[idx], sizeof(regs->esi));
-    idx += sizeof(regs->esi) * 2;
-    mem2hex ((char *)&regs->edi, &buffer[idx], sizeof(regs->edi));
-    idx += sizeof(regs->edi) * 2;
-    mem2hex ((char *)&regs->eip, &buffer[idx], sizeof(regs->eip));
-    idx += sizeof(regs->eip) * 2;
-    mem2hex ((char *)&regs->eflags, &buffer[idx], sizeof(regs->eflags));
-    idx += sizeof(regs->eflags) * 2;
-    mem2hex ((char *)&regs->cs, &buffer[idx], sizeof(regs->cs));
-    idx += sizeof(regs->cs) * 2;
-    mem2hex ((char *)&regs->ss, &buffer[idx], sizeof(regs->ss));
-    idx += sizeof(regs->ss) * 2;
-    mem2hex ((char *)&regs->ds, &buffer[idx], sizeof(regs->ds));
-    idx += sizeof(regs->ds) * 2;
-    mem2hex ((char *)&regs->es, &buffer[idx], sizeof(regs->es));
-    idx += sizeof(regs->es) * 2;
-    mem2hex ((char *)&regs->fs, &buffer[idx], sizeof(regs->fs));
-    idx += sizeof(regs->fs) * 2;
-    mem2hex ((char *)&regs->gs, &buffer[idx], sizeof(regs->gs));
-}
-
-/* at this point we allow any register to be changed, caveat emptor */
-void
-pdb_gdb_to_x86_regs (struct xen_regs *regs, char *buffer)
-{
-    hex2mem(buffer, (char *)&regs->eax, sizeof(regs->eax));
-    buffer += sizeof(regs->eax) * 2;
-    hex2mem(buffer, (char *)&regs->ecx, sizeof(regs->ecx));
-    buffer += sizeof(regs->ecx) * 2;
-    hex2mem(buffer, (char *)&regs->edx, sizeof(regs->edx));
-    buffer += sizeof(regs->edx) * 2;
-    hex2mem(buffer, (char *)&regs->ebx, sizeof(regs->ebx));
-    buffer += sizeof(regs->ebx) * 2;
-    hex2mem(buffer, (char *)&regs->esp, sizeof(regs->esp));
-    buffer += sizeof(regs->esp) * 2;
-    hex2mem(buffer, (char *)&regs->ebp, sizeof(regs->ebp));
-    buffer += sizeof(regs->ebp) * 2;
-    hex2mem(buffer, (char *)&regs->esi, sizeof(regs->esi));
-    buffer += sizeof(regs->esi) * 2;
-    hex2mem(buffer, (char *)&regs->edi, sizeof(regs->edi));
-    buffer += sizeof(regs->edi) * 2;
-    hex2mem(buffer, (char *)&regs->eip, sizeof(regs->eip));
-    buffer += sizeof(regs->eip) * 2;
-    hex2mem(buffer, (char *)&regs->eflags, sizeof(regs->eflags));
-    buffer += sizeof(regs->eflags) * 2;
-    hex2mem(buffer, (char *)&regs->cs, sizeof(regs->cs));
-    buffer += sizeof(regs->cs) * 2;
-    hex2mem(buffer, (char *)&regs->ss, sizeof(regs->ss));
-    buffer += sizeof(regs->ss) * 2;
-    hex2mem(buffer, (char *)&regs->ds, sizeof(regs->ds));
-    buffer += sizeof(regs->ds) * 2;
-    hex2mem(buffer, (char *)&regs->es, sizeof(regs->es));
-    buffer += sizeof(regs->es) * 2;
-    hex2mem(buffer, (char *)&regs->fs, sizeof(regs->fs));
-    buffer += sizeof(regs->fs) * 2;
-    hex2mem(buffer, (char *)&regs->gs, sizeof(regs->gs));
-}
-
-int
-pdb_process_command (char *ptr, struct xen_regs *regs, unsigned long cr3,
-                    int sigval)
-{
-    int length;
-    unsigned long addr;
-    int ack = 1;                           /* wait for ack in pdb_put_packet */
-    int go = 0;
-
-    TRC(printf("pdb: [%s]\n", ptr));
-
-    pdb_out_buffer[0] = 0;
-
-    if (pdb_ctx.valid == 1)
-    {
-        if (pdb_ctx.domain == -1)                        /* pdb context: xen */
-       {
-           struct domain *p;
-
-           p = &idle0_task;
-           if (p->mm.shadow_mode)
-               pdb_ctx.ptbr = pagetable_val(p->mm.shadow_table);
-           else
-               pdb_ctx.ptbr = pagetable_val(p->mm.pagetable);
-       }
-       else if (pdb_ctx.process == -1)             /* pdb context: guest os */
-       {
-           struct domain *p;
-
-           if (pdb_ctx.domain == -2)
-           {
-               p = find_last_domain();
-           }
-           else
-           {
-               p = find_domain_by_id(pdb_ctx.domain);
-           }
-           if (p == NULL)
-           {
-               printk ("pdb error: unknown domain [0x%x]\n", pdb_ctx.domain);
-               strcpy (pdb_out_buffer, "E01");
-               pdb_ctx.domain = -1;
-               goto exit;
-           }
-           if (p->mm.shadow_mode)
-               pdb_ctx.ptbr = pagetable_val(p->mm.shadow_table);
-           else
-               pdb_ctx.ptbr = pagetable_val(p->mm.pagetable);
-           put_domain(p);
-       }
-       else                                         /* pdb context: process */
-       {
-           struct domain *p;
-           unsigned long domain_ptbr;
-
-           p = find_domain_by_id(pdb_ctx.domain);
-           if (p == NULL)
-           {
-               printk ("pdb error: unknown domain [0x%x][0x%x]\n", 
-                       pdb_ctx.domain, pdb_ctx.process);
-               strcpy (pdb_out_buffer, "E01");
-               pdb_ctx.domain = -1;
-               goto exit;
-           }
-           if (p->mm.shadow_mode)
-               domain_ptbr = pagetable_val(p->mm.shadow_table);
-           else
-               domain_ptbr = pagetable_val(p->mm.pagetable);
-           put_domain(p);
-
-           pdb_ctx.ptbr = domain_ptbr;
-           /*pdb_ctx.ptbr=pdb_linux_pid_ptbr(domain_ptbr, pdb_ctx.process);*/
-       }
-
-       pdb_ctx.valid = 0;
-       TRC(printk ("pdb change context (dom:%d, proc:%d) now 0x%lx\n",
-                   pdb_ctx.domain, pdb_ctx.process, pdb_ctx.ptbr));
-    }
-
-    switch (*ptr++)
-    {
-    case '?':
-        pdb_out_buffer[0] = 'S';
-        pdb_out_buffer[1] = hexchars[sigval >> 4];
-        pdb_out_buffer[2] = hexchars[sigval % 16];
-        pdb_out_buffer[3] = 0;
-        break;
-    case 'S':                                            /* step with signal */
-    case 's':                                                        /* step */
-    {
-        if ( pdb_system_call_eflags_addr != 0 )
-       {
-           unsigned long eflags;
-           char eflags_buf[sizeof(eflags)*2];       /* STUPID STUPID STUPID */
-
-           pdb_linux_get_values((u_char*)&eflags, sizeof(eflags), 
-                                pdb_system_call_eflags_addr, 
-                                pdb_ctx.process, pdb_ctx.ptbr);
-           eflags |= X86_EFLAGS_TF;
-           mem2hex ((u_char *)&eflags, eflags_buf, sizeof(eflags)); 
-           pdb_linux_set_values(eflags_buf, sizeof(eflags),
-                                pdb_system_call_eflags_addr,
-                                pdb_ctx.process, pdb_ctx.ptbr);
-       }
-
-        regs->eflags |= X86_EFLAGS_TF;
-        pdb_stepping = 1;
-        return 1;                                        
-        /* not reached */
-    }
-    case 'C':                                        /* continue with signal */
-    case 'c':                                                    /* continue */
-    {
-        if ( pdb_system_call_eflags_addr != 0 )
-       {
-           unsigned long eflags;
-           char eflags_buf[sizeof(eflags)*2];       /* STUPID STUPID STUPID */
-
-           pdb_linux_get_values((u_char*)&eflags, sizeof(eflags), 
-                                pdb_system_call_eflags_addr, 
-                                pdb_ctx.process, pdb_ctx.ptbr);
-           eflags &= ~X86_EFLAGS_TF;
-           mem2hex ((u_char *)&eflags, eflags_buf, sizeof(eflags)); 
-           pdb_linux_set_values(eflags_buf, sizeof(eflags),
-                                pdb_system_call_eflags_addr,
-                                pdb_ctx.process, pdb_ctx.ptbr);
-       }
-
-        regs->eflags &= ~X86_EFLAGS_TF;
-        return 1;                         /* jump out before replying to gdb */
-        /* not reached */
-    }
-    case 'd':
-        remote_debug = !(remote_debug);                 /* toggle debug flag */
-        break;
-    case 'D':                                                      /* detach */
-        return go;
-        /* not reached */
-    case 'g':                       /* return the value of the CPU registers */
-    {
-        pdb_x86_to_gdb_regs (pdb_out_buffer, regs);
-        break;
-    }
-    case 'G':              /* set the value of the CPU registers - return OK */
-    {
-        pdb_gdb_to_x86_regs (regs, ptr);
-        break;
-    }
-    case 'H':
-    {
-        int thread;
-        char *next = &ptr[1];
-
-        if (hexToInt (&next, &thread))
-        {
-            if (*ptr == 'c')
-            {
-               pdb_continue_thread = thread;
-            }
-            else if (*ptr == 'g')
-            {
-               pdb_general_thread = thread;
-            }
-            else
-            {
-                printk ("pdb error: unknown set thread command %c (%d)\n", 
-                        *ptr, thread);
-               strcpy (pdb_out_buffer, "E00");
-               break;
-            }
-        }
-        strcpy (pdb_out_buffer, "OK");
-        break;
-    }
-    case 'k':                                                /* kill request */
-    {
-        strcpy (pdb_out_buffer, "OK");                        /* ack for fun */
-        printk ("don't kill bill...\n");
-        ack = 0;
-        break;
-    }
-
-    case 'q':
-    {
-        pdb_process_query(ptr);
-        break;
-    }
-
-    /* mAA..AA,LLLL  Read LLLL bytes at address AA..AA */
-    case 'm':
-    {
-        /* TRY TO READ %x,%x.  IF SUCCEED, SET PTR = 0 */
-        if (hexToInt (&ptr, (int *)&addr))
-            if (*(ptr++) == ',')
-                if (hexToInt (&ptr, &length))
-                {
-                    ptr = 0;
-
-                   pdb_page_fault_possible = 1;
-                   pdb_page_fault = 0;
-                   if (addr >= PAGE_OFFSET)
-                   {
-                        mem2hex ((char *) addr, pdb_out_buffer, length); 
-                   }
-                   else if (pdb_ctx.process != -1)
-                   {
-                       pdb_linux_get_values(pdb_buffer, length, addr, 
-                                            pdb_ctx.process, pdb_ctx.ptbr);
-                        mem2hex (pdb_buffer, pdb_out_buffer, length); 
-                   }
-                    else
-                    {
-                       pdb_get_values (pdb_buffer, length, 
-                                       pdb_ctx.ptbr, addr);
-                        mem2hex (pdb_buffer, pdb_out_buffer, length);
-                    }
-
-                   pdb_page_fault_possible = 0;
-                   if (pdb_page_fault)
-                   {
-                        strcpy (pdb_out_buffer, "E03");
-                   }
-                }
-           
-        if (ptr)
-        {
-            strcpy (pdb_out_buffer, "E01");
-        }
-        break;
-    }
-
-    /* MAA..AA,LLLL: Write LLLL bytes at address AA.AA return OK */
-    case 'M':
-    {
-        /* TRY TO READ '%x,%x:'.  IF SUCCEED, SET PTR = 0 */
-        if (hexToInt (&ptr, (int *)&addr))
-            if (*(ptr++) == ',')
-                if (hexToInt (&ptr, &length))
-                    if (*(ptr++) == ':')
-                    {
-
-                       pdb_page_fault_possible = 1;
-                       pdb_page_fault = 0;
-                       if (addr >= PAGE_OFFSET)
-                       {
-                           hex2mem (ptr, (char *)addr, length);
-                           pdb_bkpt_check(ptr, length, pdb_ctx.ptbr, addr);
-                       }
-                       else if (pdb_ctx.process != -1)
-                       {
-                           pdb_linux_set_values(ptr, length, addr,
-                                                pdb_ctx.process, 
-                                                pdb_ctx.ptbr);
-                           pdb_bkpt_check(ptr, length, pdb_ctx.ptbr, addr);
-                       }
-                       else
-                       {
-                           pdb_set_values (ptr, length,
-                                           pdb_ctx.ptbr, addr);
-                           pdb_bkpt_check(ptr, length, pdb_ctx.ptbr, addr);
-                       }
-                       pdb_page_fault_possible = 0;
-                        if (pdb_page_fault)
-                        {
-                            strcpy (pdb_out_buffer, "E03");
-                        }
-                        else
-                        {
-                            strcpy (pdb_out_buffer, "OK");
-                        }
-
-                        ptr = 0;
-                    }
-        if (ptr)
-        {
-            strcpy (pdb_out_buffer, "E02");
-        }
-        break;
-    }
-    case 'T':
-    {
-        int id;
-
-        if (hexToInt (&ptr, &id))
-        {
-           strcpy (pdb_out_buffer, "E00");
-
-#ifdef PDB_PAST
-
-           switch (pdb_level)                             /* previous level */
-           {
-               case PDB_LVL_XEN:
-               {
-                   struct domain *p;
-                   id -= PDB_ID_OFFSET;
-                   if ( (p = find_domain_by_id(id)) == NULL)
-                       strcpy (pdb_out_buffer, "E00");
-                   else
-                       strcpy (pdb_out_buffer, "OK");
-                   put_domain(p);
-
-                   pdb_level = PDB_LVL_GUESTOS;
-                   pdb_ctx[pdb_level].ctrl = id;
-                   pdb_ctx[pdb_level].info = id;
-                   break;
-               }
-               case PDB_LVL_GUESTOS:
-               {
-                   if (pdb_level == -1)
-                   {
-                       pdb_level = PDB_LVL_XEN;
-                   }
-                   else
-                   {
-                       pdb_level = PDB_LVL_PROCESS;
-                       pdb_ctx[pdb_level].ctrl = id;
-                       pdb_ctx[pdb_level].info = id;
-                   }
-                   break;
-               }
-               case PDB_LVL_PROCESS:
-               {
-                   if (pdb_level == -1)
-                   {
-                       pdb_level = PDB_LVL_GUESTOS;
-                   }
-                   break;
-               }
-               default:
-               {
-                   printk ("pdb internal error: invalid level [%d]\n", 
-                           pdb_level);
-               }
-           }
-
-#endif /* PDB_PAST */
-        }
-        break;
-    }
-    }
-
-exit:
-    /* reply to the request */
-    pdb_put_packet (pdb_out_buffer, ack);
-
-    return go;
-}
-
-/*
- * process an input character from the serial line.
- *
- * return "1" if the character is a gdb debug string
- * (and hence shouldn't be further processed).
- */
-
-int pdb_debug_state = 0;                /* small parser state machine */
-
-int hex(char ch)
-{
-    if ((ch >= 'a') && (ch <= 'f')) return (ch-'a'+10);
-    if ((ch >= '0') && (ch <= '9')) return (ch-'0');
-    if ((ch >= 'A') && (ch <= 'F')) return (ch-'A'+10);
-    return (-1);
-}
-
-/* convert the memory pointed to by mem into hex, placing result in buf */
-/* return a pointer to the last char put in buf (null) */
-char *
-mem2hex (mem, buf, count)
-    char *mem;
-    char *buf;
-    int count;
-{
-    int i;
-    unsigned char ch;
-
-    for (i = 0; i < count; i++)
-    {
-        ch = get_char (mem++);
-        *buf++ = hexchars[ch >> 4];
-        *buf++ = hexchars[ch % 16];
-    }
-    *buf = 0;
-    return (buf);
-}
-
-/* convert the hex array pointed to by buf into binary to be placed in mem */
-/* return a pointer to the character AFTER the last byte written */
-char *
-hex2mem (buf, mem, count)
-    char *buf;
-    char *mem;
-    int count;
-{
-    int i;
-    unsigned char ch;
-
-    for (i = 0; i < count; i++)
-    {
-        ch = hex (*buf++) << 4;
-        ch = ch + hex (*buf++);
-        set_char (mem++, ch);
-    }
-    return (mem);
-}
-
-int
-hexToInt (char **ptr, int *intValue)
-{
-    int numChars = 0;
-    int hexValue;
-    int negative = 0;
-
-    *intValue = 0;
-
-    if (**ptr == '-')
-    {
-        negative = 1;
-        numChars++;
-        (*ptr)++;
-    }
-
-    while (**ptr)
-    {
-        hexValue = hex (**ptr);
-        if (hexValue >= 0)
-        {
-            *intValue = (*intValue << 4) | hexValue;
-            numChars++;
-        }
-        else
-            break;
-
-        (*ptr)++;
-    }
-
-    if ( negative )
-        *intValue *= -1;
-  
-    return (numChars);
-}
-
-/***********************************************************************/
-/***********************************************************************/
-
-
-/*
- * Add a breakpoint to the list of known breakpoints.
- * For now there should only be two or three breakpoints so
- * we use a simple linked list.  In the future, maybe a red-black tree?
- */
-struct pdb_breakpoint breakpoints;
-
-void pdb_bkpt_add (unsigned long cr3, unsigned long address)
-{
-    struct pdb_breakpoint *bkpt = xmalloc(sizeof(*bkpt));
-    bkpt->cr3 = cr3;
-    bkpt->address = address;
-    list_add(&bkpt->list, &breakpoints.list);
-}
-
-/*
- * Check to see of the breakpoint is in the list of known breakpoints 
- * Return 1 if it has been set, NULL otherwise.
- */
-struct pdb_breakpoint* pdb_bkpt_search (unsigned long cr3, 
-                                       unsigned long address)
-{
-    struct pdb_breakpoint *bkpt;
-
-    list_for_each_entry ( bkpt, &breakpoints.list, list )
-    {
-       if ( bkpt->cr3 == cr3 && bkpt->address == address )
-            return bkpt;
-    }
-
-    return NULL;
-}
-
-/*
- * Remove a breakpoint to the list of known breakpoints.
- * Return 1 if the element was not found, otherwise 0.
- */
-int pdb_bkpt_remove (unsigned long cr3, unsigned long address)
-{
-    struct pdb_breakpoint *bkpt;
-
-    list_for_each_entry ( bkpt, &breakpoints.list, list )
-    {
-       if ( bkpt->cr3 == cr3 && bkpt->address == address )
-       {
-            list_del(&bkpt->list);
-            xfree(bkpt);
-            return 0;
-       }
-    }
-
-    return 1;
-}
-
-/*
- * Check to see if a memory write is really gdb setting a breakpoint
- */
-void pdb_bkpt_check (u_char *buffer, int length,
-                    unsigned long cr3, unsigned long addr)
-{
-    if (length == 1 && buffer[0] == 'c' && buffer[1] == 'c')
-    {
-        /* inserting a new breakpoint */
-        pdb_bkpt_add(cr3, addr);
-        TRC(printk("pdb breakpoint detected at 0x%lx:0x%lx\n", cr3, addr));
-    }
-    else if ( pdb_bkpt_remove(cr3, addr) == 0 )
-    {
-        /* removing a breakpoint */
-        TRC(printk("pdb breakpoint cleared at 0x%lx:0x%lx\n", cr3, addr));
-    }
-}
-
-/***********************************************************************/
-
-int pdb_change_values(u_char *buffer, int length,
-                     unsigned long cr3, unsigned long addr, int rw);
-int pdb_change_values_one_page(u_char *buffer, int length,
-                              unsigned long cr3, unsigned long addr, int rw);
-
-#define __PDB_GET_VAL 1
-#define __PDB_SET_VAL 2
-
-/*
- * Set memory in a domain's address space
- * Set "length" bytes at "address" from "domain" to the values in "buffer".
- * Return the number of bytes set, 0 if there was a problem.
- */
-
-int pdb_set_values(u_char *buffer, int length,
-                  unsigned long cr3, unsigned long addr)
-{
-    int count = pdb_change_values(buffer, length, cr3, addr, __PDB_SET_VAL);
-    return count;
-}
-
-/*
- * Read memory from a domain's address space.
- * Fetch "length" bytes at "address" from "domain" into "buffer".
- * Return the number of bytes read, 0 if there was a problem.
- */
-
-int pdb_get_values(u_char *buffer, int length,
-                  unsigned long cr3, unsigned long addr)
-{
-  return pdb_change_values(buffer, length, cr3, addr, __PDB_GET_VAL);
-}
-
-/*
- * Read or write memory in an address space
- */
-int pdb_change_values(u_char *buffer, int length,
-                     unsigned long cr3, unsigned long addr, int rw)
-{
-    int remaining;                /* number of bytes to touch past this page */
-    int bytes = 0;
-
-    while ( (remaining = (addr + length - 1) - (addr | (PAGE_SIZE - 1))) > 0)
-    {
-        bytes += pdb_change_values_one_page(buffer, length - remaining, 
-                                           cr3, addr, rw);
-       buffer = buffer + (2 * (length - remaining));
-       length = remaining;
-       addr = (addr | (PAGE_SIZE - 1)) + 1;
-    }
-
-    bytes += pdb_change_values_one_page(buffer, length, cr3, addr, rw);
-    return bytes;
-}
-
-/*
- * Change memory in a process' address space in one page
- * Read or write "length" bytes at "address" into/from "buffer"
- * from the virtual address space referenced by "cr3".
- * Return the number of bytes read, 0 if there was a problem.
- */
-
-int pdb_change_values_one_page(u_char *buffer, int length,
-                              unsigned long cr3, unsigned long addr, int rw)
-{
-    l2_pgentry_t* l2_table = NULL;                         /* page directory */
-    l1_pgentry_t* l1_table = NULL;                             /* page table */
-    u_char *page;                                                 /* 4k page */
-    int bytes = 0;
-
-    l2_table = map_domain_mem(cr3); 
-    l2_table += l2_table_offset(addr);
-    if (!(l2_pgentry_val(*l2_table) & _PAGE_PRESENT)) 
-    {
-       if (pdb_page_fault_possible == 1)
-       {
-           pdb_page_fault = 1;
-           TRC(printk("pdb: L2 error (0x%lx)\n", addr));
-       }
-       else
-       {
-           printk ("pdb error: cr3: 0x%lx    dom0cr3:  0x%lx\n",  cr3,
-                   dom0->mm.shadow_mode ? pagetable_val(dom0->mm.shadow_table)
-                   : pagetable_val(dom0->mm.pagetable));
-           printk ("pdb error: L2:0x%p (0x%lx)\n", 
-                   l2_table, l2_pgentry_val(*l2_table));
-       }
-       goto exit2;
-    }
-
-    if (l2_pgentry_val(*l2_table) & _PAGE_PSE)
-    {
-#define PSE_PAGE_SHIFT           L2_PAGETABLE_SHIFT
-#define PSE_PAGE_SIZE           (1UL << PSE_PAGE_SHIFT)
-#define PSE_PAGE_MASK           (~(PSE_PAGE_SIZE-1))
-
-#define L1_PAGE_BITS ( (ENTRIES_PER_L1_PAGETABLE - 1) << L1_PAGETABLE_SHIFT )
-
-#define pse_pgentry_to_phys(_x) (l2_pgentry_val(_x) & PSE_PAGE_MASK)
-
-        page = map_domain_mem(pse_pgentry_to_phys(*l2_table) +    /* 10 bits */
-                             (addr & L1_PAGE_BITS));             /* 10 bits */
-       page += addr & (PAGE_SIZE - 1);                           /* 12 bits */
-    }
-    else
-    {
-        l1_table = map_domain_mem(l2_pgentry_to_phys(*l2_table));
-       l1_table += l1_table_offset(addr); 
-       if (!(l1_pgentry_val(*l1_table) & _PAGE_PRESENT))
-       {
-           if (pdb_page_fault_possible == 1)
-           {
-               pdb_page_fault = 1;
-               TRC(printk ("pdb: L1 error (0x%lx)\n", addr));
-           }
-           else
-           {
-               printk ("L2:0x%p (0x%lx) L1:0x%p (0x%lx)\n", 
-                       l2_table, l2_pgentry_val(*l2_table),
-                       l1_table, l1_pgentry_val(*l1_table));
-           }
-           goto exit1;
-       }
-
-       page = map_domain_mem(l1_pgentry_to_phys(*l1_table));
-       page += addr & (PAGE_SIZE - 1);
-    }
-
-    switch (rw)
-    {
-    case __PDB_GET_VAL:                                              /* read */
-        memcpy (buffer, page, length);
-       bytes = length;
-       break;
-    case __PDB_SET_VAL:                                             /* write */
-        hex2mem (buffer, page, length);
-       bytes = length;
-       break;
-    default:                                                      /* unknown */
-        printk ("error: unknown RW flag: %d\n", rw);
-       return 0;
-    }
-
-    unmap_domain_mem((void *)page); 
-exit1:
-    if (l1_table != NULL)
-        unmap_domain_mem((void *)l1_table);
-exit2:
-    unmap_domain_mem((void *)l2_table);
-
-    return bytes;
-}
-
-/***********************************************************************/
-
-void breakpoint(void);
-
-/* send the packet in buffer.  */
-void pdb_put_packet (unsigned char *buffer, int ack)
-{
-    unsigned char checksum;
-    int count;
-    char ch;
-    
-    /*  $<packet info>#<checksum> */
-    /*  do */
-    {
-        pdb_put_char ('$');
-       checksum = 0;
-       count = 0;
-
-       while ((ch = buffer[count]))
-       {
-            pdb_put_char (ch);
-           checksum += ch;
-           count += 1;
-        }
-
-       pdb_put_char('#');
-       pdb_put_char(hexchars[checksum >> 4]);
-       pdb_put_char(hexchars[checksum % 16]);
-    }
-
-    if (ack)
-    {
-       if ((ch = pdb_get_char()) != '+')
-       {
-           printk(" pdb return error: %c 0x%x [%s]\n", ch, ch, buffer);
-       }
-    }
-}
-
-void pdb_get_packet(char *buffer)
-{
-    int count;
-    char ch;
-    unsigned char checksum = 0;
-    unsigned char xmitcsum = 0;
-
-    do
-    {
-        while ((ch = pdb_get_char()) != '$');
-
-       count = 0;
-       checksum = 0;
-
-       while (count < BUFMAX)
-       {
-           ch = pdb_get_char();
-           if (ch  == '#') break;
-           checksum += ch;
-           buffer[count] = ch;
-           count++;
-       }
-       buffer[count] = 0;
-
-       if (ch == '#')
-       {
-           xmitcsum = hex(pdb_get_char()) << 4;
-           xmitcsum += hex(pdb_get_char());
-
-           if (xmitcsum == checksum)
-           {
-               pdb_put_char('+');
-               if (buffer[2] == ':')
-               {
-                   printk ("pdb: obsolete gdb packet (sequence ID)\n");
-               }
-           }
-           else
-           {
-               pdb_put_char('-');
-           }
-       }
-    } while (checksum != xmitcsum);
-
-    return;
-}
-
-/*
- * process a machine interrupt or exception
- * Return 1 if pdb is not interested in the exception; it should
- * be propagated to the guest os.
- */
-
-int pdb_handle_exception(int exceptionVector,
-                        struct xen_regs *xen_regs)
-{
-    int signal = 0;
-    struct pdb_breakpoint* bkpt;
-    int watchdog_save;
-    unsigned long cr3 = read_cr3();
-
-    /* No vm86 handling here as yet. */
-    if ( VM86_MODE(xen_regs) )
-        return 1;
-
-    /* If the exception is an int3 from user space then pdb is only
-       interested if it re-wrote an instruction set the breakpoint.
-       This occurs when leaving a system call from a domain.
-    */
-    if ( (exceptionVector == 3) &&
-        RING_3(xen_regs) && 
-        (xen_regs->eip != (pdb_system_call_next_addr + 1)) )
-    {
-        TRC(printf("pdb: user bkpt (0x%x) at 0x%x:0x%lx:0x%x\n", 
-                  exceptionVector, xen_regs->cs & 3, cr3, xen_regs->eip));
-       return 1;
-    }
-
-    /*
-     * If PDB didn't set the breakpoint, is not single stepping, 
-     * is not entering a system call in a domain,
-     * the user didn't press the magic debug key, 
-     * then we don't handle the exception.
-     */
-    bkpt = pdb_bkpt_search(cr3, xen_regs->eip - 1);
-    if ( (bkpt == NULL) &&
-         !pdb_stepping && 
-        !pdb_system_call &&
-        xen_regs->eip != pdb_system_call_next_addr + 1 &&
-        (exceptionVector != KEYPRESS_EXCEPTION) &&
-        xen_regs->eip < 0xc0000000)  /* Linux-specific for now! */
-    {
-        TRC(printf("pdb: user bkpt (0x%x) at 0x%lx:0x%x\n", 
-                  exceptionVector, cr3, xen_regs->eip));
-       return 1;
-    }
-
-    printk("pdb_handle_exception [0x%x][0x%lx:0x%x]\n",
-          exceptionVector, cr3, xen_regs->eip);
-
-    if ( pdb_stepping )
-    {
-        /* Stepped one instruction; now return to normal execution. */
-        xen_regs->eflags &= ~X86_EFLAGS_TF;
-        pdb_stepping = 0;
-    }
-
-    if ( pdb_system_call )
-    {
-       pdb_system_call = 0;
-
-       pdb_linux_syscall_exit_bkpt (xen_regs, &pdb_ctx);
-
-       /* we don't have a saved breakpoint so we need to rewind eip */
-       xen_regs->eip--;
-       
-       /* if ther user doesn't care about breaking when entering a
-          system call then we'll just ignore the exception */
-       if ( (pdb_ctx.system_call & 0x01) == 0 )
-       {
-           return 0;
-       }
-    }
-
-    if ( exceptionVector == BREAKPT_EXCEPTION && bkpt != NULL)
-    {
-        /* Executed Int3: replace breakpoint byte with real program byte. */
-        xen_regs->eip--;
-    }
-
-    /* returning to user space after a system call */
-    if ( xen_regs->eip == pdb_system_call_next_addr + 1)
-    {
-        u_char instr[2];                      /* REALLY REALLY REALLY STUPID */
-
-       mem2hex (&pdb_system_call_leave_instr, instr, sizeof(instr)); 
-
-       pdb_linux_set_values (instr, 1, pdb_system_call_next_addr,
-                             pdb_ctx.process, pdb_ctx.ptbr);
-
-       pdb_system_call_next_addr = 0;
-       pdb_system_call_leave_instr = 0;
-
-       /* manually rewind eip */
-       xen_regs->eip--;
-
-       /* if the user doesn't care about breaking when returning 
-          to user space after a system call then we'll just ignore 
-          the exception */
-       if ( (pdb_ctx.system_call & 0x02) == 0 )
-       {
-           return 0;
-       }
-    }
-
-    /* Generate a signal for GDB. */
-    switch ( exceptionVector )
-    {
-    case KEYPRESS_EXCEPTION:
-        signal = 2; break;                                  /* SIGINT */
-    case DEBUG_EXCEPTION:
-        signal = 5; break;                                 /* SIGTRAP */
-    case BREAKPT_EXCEPTION: 
-        signal = 5; break;                                 /* SIGTRAP */
-    default:
-        printk("pdb: can't generate signal for unknown exception vector %d\n",
-               exceptionVector);
-        break;
-    }
-
-    pdb_out_buffer[0] = 'S';
-    pdb_out_buffer[1] = hexchars[signal >> 4];
-    pdb_out_buffer[2] = hexchars[signal % 16];
-    pdb_out_buffer[3] = 0;
-    pdb_put_packet(pdb_out_buffer, 1);
-
-    watchdog_save = watchdog_on;
-    watchdog_on = 0;
-
-    do {
-        pdb_out_buffer[0] = 0;
-       pdb_get_packet(pdb_in_buffer);
-    }
-    while ( pdb_process_command(pdb_in_buffer, xen_regs, cr3, signal) == 0 );
-
-    watchdog_on = watchdog_save;
-
-    return 0;
-}
-
-void pdb_key_pressed(unsigned char key)
-{
-    struct xen_regs *regs = (struct xen_regs *)get_execution_context();
-    pdb_handle_exception(KEYPRESS_EXCEPTION, regs);
-}
-
-void pdb_handle_debug_trap(struct xen_regs *regs, long error_code)
-{
-    unsigned int condition;
-    struct domain *d = current;
-    struct trap_bounce *tb = &d->thread.trap_bounce;
-
-    __asm__ __volatile__("movl %%db6,%0" : "=r" (condition));
-    if ( (condition & (1 << 14)) != (1 << 14) )
-        printk("\nwarning: debug trap w/o BS bit [0x%x]\n\n", condition);
-    __asm__("movl %0,%%db6" : : "r" (0));
-
-    if ( pdb_handle_exception(1, regs) != 0 )
-    {
-        d->thread.debugreg[6] = condition;
-
-        tb->flags = TBF_EXCEPTION;
-        tb->cs    = d->thread.traps[1].cs;
-        tb->eip   = d->thread.traps[1].address;
-    }
-}
-
-void initialize_pdb()
-{
-    /* Certain state must be initialised even when PDB will not be used. */
-    memset((void *) &breakpoints, 0, sizeof(breakpoints));
-    INIT_LIST_HEAD(&breakpoints.list);
-    pdb_stepping = 0;
-
-    if ( strcmp(opt_pdb, "none") == 0 )
-        return;
-
-    if ( (pdb_serhnd = parse_serial_handle(opt_pdb)) == -1 )
-    {
-        printk("error: failed to initialize PDB on port %s\n", opt_pdb);
-        return;
-    }
-
-    pdb_ctx.valid = 1;
-    pdb_ctx.domain = -1;
-    pdb_ctx.process = -1;
-    pdb_ctx.system_call = 0;
-    pdb_ctx.ptbr = 0;
-
-    printk("pdb: pervasive debugger (%s)   www.cl.cam.ac.uk/netos/pdb\n", 
-          opt_pdb);
-
-    /* Acknowledge any spurious GDB packets. */
-    pdb_put_char('+');
-
-    register_keyhandler('D', pdb_key_pressed, "enter pervasive debugger");
-
-    pdb_initialized = 1;
-}
-
-void breakpoint(void)
-{
-    if ( pdb_initialized )
-        asm("int $3");
-}
index c31b4be199a6af6c697428eee752b3b02b740d6f..e05643be990b2ad72f7bb4b4aa848bb15554cbf4 100644 (file)
@@ -17,7 +17,6 @@
 #include <asm/apic.h>
 #include <asm/desc.h>
 #include <asm/domain_page.h>
-#include <asm/pdb.h>
 #include <asm/shadow.h>
 #include <asm/e820.h>
 
@@ -427,10 +426,6 @@ static void __init start_of_day(void)
 
     serial_init_stage2();
 
-#ifdef XEN_DEBUGGER
-    initialize_pdb();      /* pervasive debugger */
-#endif
-
     if ( !cpu_has_apic )
     {
         do_timer_lists_from_pit = 1;
index fb1ded89454768718705270432c66c883f95ac32..2fc8bb4f5543578195355acd60263e25ed8e1ab0 100644 (file)
@@ -1,4 +1,4 @@
-/* -*-  Mode:C++; c-file-style:BSD; c-basic-offset:4; tab-width:4 -*- */
+/* -*-  Mode:C; c-basic-offset:4; tab-width:4; indent-tabs-mode:nil -*- */
 
 #include <xen/config.h>
 #include <xen/types.h>
@@ -495,7 +495,7 @@ unsigned long shadow_l2_table(
             mk_l2_pgentry((spfn << PAGE_SHIFT) | __PAGE_HYPERVISOR);
         spl2e[PERDOMAIN_VIRT_START >> L2_PAGETABLE_SHIFT] =
             mk_l2_pgentry(__pa(page_get_owner(&frame_table[gpfn])->mm_perdomain_pt) |
-                         __PAGE_HYPERVISOR);
+                          __PAGE_HYPERVISOR);
     }
 #endif
 
index 3ff5e7f135648ac44c0a2bbe97879ed0b132e4aa..ebc772dee6716e72744d442d8106d7715e0a8685 100644 (file)
@@ -1,4 +1,4 @@
-/* -*-  Mode:C; c-basic-offset:4; tab-width:4 -*-
+/* -*-  Mode:C; c-basic-offset:4; tab-width:4; indent-tabs-mode:nil -*-
  ****************************************************************************
  * (C) 2002-2003 - Rolf Neugebauer - Intel Research Cambridge
  * (C) 2002-2003 University of Cambridge
index eb8d1b1f99863250e78e23629912564aa4d71395..34dbb44175a31e1d67e4edb89e5c300a1678cd0b 100644 (file)
@@ -9,11 +9,6 @@ OBJS := $(subst physdev.o,,$(OBJS))
 OBJS := $(subst xmalloc.o,,$(OBJS))
 endif
 
-ifneq ($(debugger),y)
-OBJS := $(subst debug.o,,$(OBJS))
-OBJS := $(subst debug-linux.o,,$(OBJS))
-endif
-
 ifneq ($(perfc),y)
 OBJS := $(subst perfc.o,,$(OBJS))
 endif
index 6896e9945a39ed66fb44198c1d88d1f6e9efc03f..22c67aac22ff8c222ac111754451dfda16047fb2 100644 (file)
@@ -1,4 +1,4 @@
-/* -*-  Mode:C; c-basic-offset:4; tab-width:4 -*-
+/* -*-  Mode:C; c-basic-offset:4; tab-width:4; indent-tabs-mode:nil -*-
  ****************************************************************************
  * (C) 2002-2003 - Rolf Neugebauer - Intel Research Cambridge
  * (C) 2002-2003 University of Cambridge
diff --git a/xen/common/debug-linux.c b/xen/common/debug-linux.c
deleted file mode 100644 (file)
index 03c4995..0000000
+++ /dev/null
@@ -1,267 +0,0 @@
-
-/*
- * pervasive debugger
- * www.cl.cam.ac.uk/netos/pdb
- *
- * alex ho
- * 2004
- * university of cambridge computer laboratory
- *
- * linux specific pdb stuff 
- */
-
-#include <xen/config.h>
-#include <xen/types.h>
-#include <xen/lib.h>
-#include <public/dom0_ops.h>
-#include <asm/pdb.h>
-
-/* from linux/sched.h */
-#define PIDHASH_SZ (4096 >> 2)
-#define pid_hashfn(x)  ((((x) >> 8) ^ (x)) & (PIDHASH_SZ - 1))
-
-/* from asm-xen/pgtable-2level.h */
-#define PGDIR_SHIFT    22
-#define PTRS_PER_PGD   1024
-
-/* from asm-xen/page.h */
-#define PAGE_SHIFT     12
-#define PAGE_SIZE      (1UL << PAGE_SHIFT)
-#define PAGE_MASK      (~(PAGE_SIZE-1))
-
-#define __PAGE_OFFSET          (0xC0000000)
-#define PAGE_OFFSET            ((unsigned long)__PAGE_OFFSET)
-#define __pa(x)                        ((unsigned long)(x)-PAGE_OFFSET)
-#define __va(x)                        ((void *)((unsigned long)(x)+PAGE_OFFSET))
-
-/* from debug.h */
-#define ENTRIES_PER_L1_PAGETABLE 1024
-#define L1_PAGE_BITS ( (ENTRIES_PER_L1_PAGETABLE - 1) << PAGE_SHIFT )
-
-void pdb_linux_process_details (unsigned long cr3, int pid, char *buffer);
-
-/* adapted from asm-xen/page.h */
-static inline unsigned long machine_to_phys(unsigned long cr3,
-                                            unsigned long machine)
-{
-  unsigned long phys;
-  pdb_get_values((u_char *) &phys, sizeof(phys), cr3,
-                (unsigned long) machine_to_phys_mapping + 
-                 (machine >> PAGE_SHIFT) * 4);
-  phys = (phys << PAGE_SHIFT) | (machine & ~PAGE_MASK);
-  return phys;
-}
-
-unsigned long pdb_pidhash_addr         = 0xc01971e0UL;
-unsigned long pdb_init_task_union_addr = 0xc0182000UL;
-
-
-unsigned int task_struct_mm_offset           = 0x2c;
-unsigned int task_struct_next_task_offset    = 0x48;
-unsigned int task_struct_pid_offset          = 0x7c;
-unsigned int task_struct_pidhash_next_offset = 0xb0;
-unsigned int task_struct_comm_offset         = 0x23e;
-unsigned int task_struct_comm_length         = 0x10;
-
-unsigned int mm_struct_pgd_offset            = 0x0c;
-
-/*
- * find the task structure of a process (pid)
- * given the cr3 of the guest os.
- */
-unsigned long pdb_linux_pid_task_struct (unsigned long cr3, int pid)
-{
-  unsigned long task_struct_p = (unsigned long) NULL;
-  unsigned long task_struct_pid;
-
-  /* find the task_struct of the given process */
-  pdb_get_values((u_char *) &task_struct_p, sizeof(task_struct_p),
-                cr3, pdb_pidhash_addr + pid_hashfn(pid) * 4);
-
-  /* find the correct task struct */
-  while (task_struct_p != (unsigned long)NULL)
-  {
-    pdb_get_values((u_char *) &task_struct_pid, sizeof(task_struct_pid),
-                  cr3, task_struct_p + task_struct_pid_offset);
-    if (task_struct_pid == pid)
-    {
-      break;
-    }
-
-    pdb_get_values((u_char *) &task_struct_p, sizeof(task_struct_p),
-                  cr3, task_struct_p + task_struct_pidhash_next_offset);
-  }
-  if (task_struct_p == (unsigned long) NULL)
-  {
-    /* oops */
-    printk ("pdb error: couldn't find process 0x%x (0x%lx)\n", pid, cr3);
-  }
-
-  return task_struct_p;
-}
-
-/*
- * find the ptbr of a process (pid)
- * given the cr3 of the guest os.
- */
-unsigned long pdb_linux_pid_ptbr (unsigned long cr3, int pid)
-{
-  unsigned long task_struct_p;
-  unsigned long mm_p, pgd;
-
-  task_struct_p = pdb_linux_pid_task_struct(cr3, pid);
-  if (task_struct_p == (unsigned long) NULL)
-  {
-    return (unsigned long) NULL;
-  }
-
-  /* get the mm_struct within the task_struct */
-  pdb_get_values((u_char *) &mm_p, sizeof(mm_p),
-                cr3, task_struct_p + task_struct_mm_offset);
-  /* get the page global directory (cr3) within the mm_struct */
-  pdb_get_values((u_char *) &pgd, sizeof(pgd),
-                cr3, mm_p + mm_struct_pgd_offset);
-
-  return pgd;
-}
-
-
-
-/* read a byte from a process 
- *
- * in: pid: process id
- *     cr3: ptbr for the process' domain
- *     addr: address to read
- */
-
-u_char pdb_linux_get_value(int pid, unsigned long cr3, unsigned long addr)
-{
-  u_char result = 0;
-  unsigned long pgd;
-  unsigned long l2tab, page;
-
-  /* get the process' pgd */
-  pgd = pdb_linux_pid_ptbr(cr3, pid);
-
-  /* get the l2 table entry */
-  pdb_get_values((u_char *) &l2tab, sizeof(l2tab),
-                cr3, pgd + (addr >> PGDIR_SHIFT) * 4);
-  l2tab = (unsigned long)__va(machine_to_phys(cr3, l2tab) & PAGE_MASK);
-
-  /* get the page table entry */
-  pdb_get_values((u_char *) &page, sizeof(page),
-                cr3, l2tab + ((addr & L1_PAGE_BITS) >> PAGE_SHIFT) * 4);
-  page = (unsigned long)__va(machine_to_phys(cr3, page) & PAGE_MASK);
-
-  /* get the byte */
-  pdb_get_values((u_char *) &result, sizeof(result),
-                cr3, page + (addr & ~PAGE_MASK));
-
-  return result;
-}
-
-void pdb_linux_get_values(char *buffer, int length, unsigned long address,
-                         int pid, unsigned long cr3)
-{
-    int loop;
-
-    /* yes, this can be optimized... a lot */
-    for (loop = 0; loop < length; loop++)
-    {
-        buffer[loop] = pdb_linux_get_value(pid, cr3, address + loop);
-    }
-}
-
-void pdb_linux_set_value(int pid, unsigned long cr3, unsigned long addr,
-                        u_char *value)
-{
-    unsigned long pgd;
-    unsigned long l2tab, page;
-    /* get the process' pgd */
-    pgd = pdb_linux_pid_ptbr(cr3, pid);
-    /* get the l2 table entry */
-    pdb_get_values((u_char *) &l2tab, sizeof(l2tab),
-                  cr3, pgd + (addr >> PGDIR_SHIFT) * 4);
-    l2tab = (unsigned long)__va(machine_to_phys(cr3, l2tab) & PAGE_MASK);
-    /* get the page table entry */
-    pdb_get_values((u_char *) &page, sizeof(page),
-                  cr3, l2tab + ((addr & L1_PAGE_BITS) >> PAGE_SHIFT) * 4);
-    page = (unsigned long)__va(machine_to_phys(cr3, page) & PAGE_MASK);
-    /* set the byte */
-    pdb_set_values(value, sizeof(u_char), cr3, page + (addr & ~PAGE_MASK));
-}
-void pdb_linux_set_values(char *buffer, int length, unsigned long address,
-                         int pid, unsigned long cr3)
-{
-    int loop;
-    /* it's difficult to imagine a more inefficient algorithm */
-    for (loop = 0; loop < length; loop++)
-    {
-        pdb_linux_set_value(pid, cr3, address + loop, &buffer[loop * 2]);
-    }
-}
-
-/**********************************************************************/
-
-/*
- * return 1 if is the virtual address is in the operating system's
- * address space, else 0 
- */
-int pdb_linux_address_space (unsigned long addr)
-{
-    return (addr > PAGE_OFFSET);
-}
-
-/* get a list of at most "max" processes
- * return: number of threads found
- *
- *   init_task -> init_task_union.task
- *   while (next_task != init_task) {}
- */
-int pdb_linux_process_list (unsigned long cr3, int array[], int max)
-{
-  unsigned long task_p, next_p;
-  int pid;
-  int count = 0;
-
-  /* task_p = init_task->next_task  */
-  pdb_get_values((u_char *) &task_p, sizeof(task_p),
-                cr3, pdb_init_task_union_addr + task_struct_next_task_offset);
-  
-  while (task_p != pdb_init_task_union_addr)
-  {
-      pdb_get_values((u_char *) &pid, sizeof(pid),
-                    cr3, task_p + task_struct_pid_offset);
-
-      array[count % max] = pid;
-      count++;
-
-      pdb_get_values((u_char *) &next_p, sizeof(next_p),
-                    cr3, task_p + task_struct_next_task_offset);
-      task_p = next_p;
-  }
-
-  return count;
-}
-
-/*
- * get additional details about a particular process
- */
-void pdb_linux_process_details (unsigned long cr3, int pid, char *buffer)
-{
-  unsigned long task_struct_p;
-
-  task_struct_p = pdb_linux_pid_task_struct(cr3, pid);
-
-  pdb_get_values((u_char *) buffer, task_struct_comm_length,
-                cr3, task_struct_p + task_struct_comm_offset);
-  return;
-}
-
diff --git a/xen/common/debug.c b/xen/common/debug.c
deleted file mode 100644 (file)
index fa99d6b..0000000
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * debug.c
- *
- * xen pervasive debugger
- */
-
-#include <xen/config.h>
-#include <xen/types.h>
-#include <xen/lib.h>
-#include <public/dom0_ops.h>
-#include <xen/sched.h>
-#include <xen/event.h>
-#include <asm/page.h>
-#include <asm/pdb.h>
-#include <asm/shadow.h>
-
-#undef DEBUG_TRACE
-#ifdef DEBUG_TRACE
-#define TRC(_x) _x
-#else
-#define TRC(_x)
-#endif
-
-/****************************************************************************/
-
-extern u_char pdb_linux_get_value(int pid, unsigned long cr3, 
-                                 unsigned long addr);
-
-/*
- * interactively call pervasive debugger from a privileged domain
- */
-void pdb_do_debug (dom0_op_t *op)
-{
-    op->u.debug.status = 0;
-
-    TRC(printk("PDB: op:%c, dom:%llu, in1:%x, in2:%x, in3:%x, in4:%x\n",
-              op->u.debug.opcode, op->u.debug.domain,
-              op->u.debug.in1, op->u.debug.in2,
-              op->u.debug.in3, op->u.debug.in4));
-
-    /* NOT NOW
-    if (op->u.debug.domain == 0)
-    {
-        op->u.debug.status = 1;
-       return;
-    }
-    */
-
-    switch (op->u.debug.opcode)
-    {
-        case 'c' :
-       {
-           struct domain *d = find_domain_by_id(op->u.debug.domain);
-           if ( d != NULL )
-           {
-                domain_unpause_by_systemcontroller(d);
-               put_domain(d);
-           }
-           else
-           {
-               op->u.debug.status = 2;                    /* invalid domain */
-           }
-           break;
-       }
-        case 'r' :
-        {
-            int loop;
-            u_char x;
-           unsigned long cr3;
-           struct domain *d;
-
-           d = find_domain_by_id(op->u.debug.domain);
-           if ( shadow_mode(d) )
-             cr3 = pagetable_val(d->mm.shadow_table);
-           else
-             cr3 = pagetable_val(d->mm.pagetable);
-
-            for (loop = 0; loop < op->u.debug.in2; loop++)         /* length */
-            { 
-                if (loop % 8 == 0)
-                {
-                    printk ("\n%08x ", op->u.debug.in1 + loop);
-                }
-                x = pdb_linux_get_value(op->u.debug.in3,
-                                       cr3, op->u.debug.in1 + loop);
-                printk (" %02x", x);
-            }
-            printk ("\n");
-           put_domain(d);
-            break;
-        }
-        case 's' :
-       {
-           struct domain *d = find_domain_by_id(op->u.debug.domain);
-
-           if ( d != NULL )
-           {
-                domain_pause_by_systemcontroller(d);
-               put_domain(d);
-           }
-           else
-           {
-               op->u.debug.status = 2;                    /* invalid domain */
-           }
-           break;
-       }
-        default :
-       {
-           printk("PDB error: unknown debug opcode %c (0x%x)\n",
-                  op->u.debug.opcode, op->u.debug.opcode);
-       }
-    }
-}
index be3e41769a92b8db16b9dd85b50a69e11a2c234d..e59bed3a3a83ce0f8aa4ac7840e8f4fea293f3ef 100644 (file)
@@ -1,3 +1,4 @@
+/* -*-  Mode:C; c-basic-offset:4; tab-width:4; indent-tabs-mode:nil -*- */
 /******************************************************************************
  * dom0_ops.c
  * 
@@ -14,7 +15,6 @@
 #include <xen/sched.h>
 #include <xen/event.h>
 #include <asm/domain_page.h>
-#include <asm/pdb.h>
 #include <xen/trace.h>
 #include <xen/console.h>
 #include <asm/shadow.h>
@@ -374,16 +374,6 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
     }
     break;
 
-#ifdef XEN_DEBUGGER
-    case DOM0_DEBUG:
-    {
-        pdb_do_debug(op);
-        copy_to_user(u_dom0_op, op, sizeof(*op));
-        ret = 0;
-    }
-    break;
-#endif
-
     case DOM0_SETTIME:
     {
         do_settime(op->u.settime.secs, 
index ef558a73543381c24efb360dd5e7d468fe714d65..f9fae770fc3064ff2324c5ceab377a4427a95f9a 100644 (file)
@@ -1,3 +1,4 @@
+/* -*-  Mode:C; c-basic-offset:4; tab-width:4; indent-tabs-mode:nil -*- */
 /******************************************************************************
  * dom_mem_ops.c
  *
@@ -141,7 +142,7 @@ do_dom_mem_op(unsigned long  op,
     else if ( unlikely(!IS_PRIV(current->domain)) )
         return -EPERM;
     else if ( unlikely((d = find_domain_by_id(domid)) == NULL) )
-       return -ESRCH;
+        return -ESRCH;
 
     LOCK_BIGLOCK(d);
 
@@ -150,18 +151,18 @@ do_dom_mem_op(unsigned long  op,
     case MEMOP_increase_reservation:
         rc = alloc_dom_mem(
             d, extent_list, start_extent, nr_extents, extent_order);
-       break;
+        break;
     case MEMOP_decrease_reservation:
         rc = free_dom_mem(
             d, extent_list, start_extent, nr_extents, extent_order);
-       break;
+        break;
     default:
         rc = -ENOSYS;
         break;
     }
 
     if ( unlikely(domid != DOMID_SELF) )
-       put_domain(d);
+        put_domain(d);
 
     UNLOCK_BIGLOCK(d);
 
index b2e6360ddcd62821052d1b7bca61922f0fe637f3..a77e77384ef8ba99416834c4ab503579e4167efb 100644 (file)
@@ -1,3 +1,4 @@
+/* -*-  Mode:C; c-basic-offset:4; tab-width:4; indent-tabs-mode:nil -*- */
 /******************************************************************************
  * domain.c
  * 
index df237af36233c6881f01a315e3103870380b1249..7c94dab5e21ba0d08e3f96448ef688584c92d00d 100644 (file)
@@ -1,3 +1,4 @@
+/* -*-  Mode:C; c-basic-offset:4; tab-width:4; indent-tabs-mode:nil -*- */
 /******************************************************************************
  * elf.c
  * 
index 304172ba265077b2a30d85e5cf66045982d69099..a55ea94e85e3501408a33bd43b6fd889c376a50b 100644 (file)
@@ -1,3 +1,4 @@
+/* -*-  Mode:C; c-basic-offset:4; tab-width:4; indent-tabs-mode:nil -*- */
 /******************************************************************************
  * event_channel.c
  * 
index e6a76c9dd67bea60f9f1d04409e7095a033ad2ce..2a7b62f9f71c706209a38164eead957858ce5f1c 100644 (file)
@@ -1,3 +1,4 @@
+/* -*-  Mode:C; c-basic-offset:4; tab-width:4; indent-tabs-mode:nil -*- */
 /******************************************************************************
  * common/grant_table.c
  * 
@@ -574,7 +575,7 @@ grant_table_create(
 
     /* Active grant table. */
     if ( (t->active = xmalloc_array(active_grant_entry_t, NR_GRANT_ENTRIES))
-        == NULL )
+         == NULL )
         goto no_mem;
     memset(t->active, 0, sizeof(active_grant_entry_t) * NR_GRANT_ENTRIES);
 
index 3b562ed7b7c0631a1a4987f3cfce475331feb2e2..e02654b053953d4e529215609ceda8e7a7a4c244 100644 (file)
@@ -1,3 +1,4 @@
+/* -*-  Mode:C; c-basic-offset:4; tab-width:4; indent-tabs-mode:nil -*- */
 /******************************************************************************
  * kernel.c
  * 
index e99d5a638167d627440ca6e92b107740f0f13cbc..1b9527aa896bbf74572393544683f0e18bfd4a74 100644 (file)
@@ -1,3 +1,4 @@
+/* -*-  Mode:C; c-basic-offset:4; tab-width:4; indent-tabs-mode:nil -*- */
 /******************************************************************************
  * keyhandler.c
  */
index b01d5a17273a0780594ae6ec37cc76c294160fdb..d3f11e0fdd4fa6c8b00f17fdf3f1aaeb417d6ff7 100644 (file)
@@ -1,3 +1,4 @@
+/* -*-  Mode:C; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- */
 
 #include <xen/ctype.h>
 #include <xen/lib.h>
@@ -394,9 +395,9 @@ __udivdi3(a, b)
  */
 u64 __umoddi3(u64 a, u64 b)
 {
-    u64 rem;
-    __qdivrem(a, b, &rem);
-    return rem;
+       u64 rem;
+       __qdivrem(a, b, &rem);
+       return rem;
 }
 
 /*
@@ -425,19 +426,18 @@ s64 __moddi3(s64 a, s64 b)
                ub = b, neg2 = 0;
        __qdivrem(ua, ub, &urem);
     
-    /* There 4 different cases: */
-    if(neg1)
-    {
-        if(neg2)
-            return -urem;
-        else
-            return ub - urem;
-    }   
-    else
-        if(neg2)
-            return -ub + urem;
-        else
-            return urem;
+       /* There 4 different cases: */
+       if (neg1) {
+               if (neg2)
+                       return -urem;
+               else
+                       return ub - urem;
+       } else {
+               if (neg2)
+                       return -ub + urem;
+               else
+                       return urem;
+       }
 }
 
 #endif /* BITS_PER_LONG == 32 */
index 04605ebb2aa0f014756b47d5db304d561eb83b7a..112a9f31767c63f7286fc2a010c270dd19cd2eb8 100644 (file)
@@ -1,3 +1,4 @@
+/* -*-  Mode:C; c-basic-offset:4; tab-width:4; indent-tabs-mode:nil -*- */
 /******************************************************************************
  * multicall.c
  */
index 8afa482da103351317a1e5bebd39ca609b7440d2..5fc2a14668b946c8566e6e03081e995264650889 100644 (file)
@@ -1,3 +1,4 @@
+/* -*-  Mode:C; c-basic-offset:4; tab-width:4; indent-tabs-mode:nil -*- */
 /******************************************************************************
  * page_alloc.c
  * 
@@ -262,8 +263,8 @@ struct pfn_info *alloc_heap_pages(unsigned int zone, unsigned int order)
 
     /* Find smallest order which can satisfy the request. */
     for ( i = order; i <= MAX_ORDER; i++ )
-       if ( !list_empty(&heap[zone][i]) )
-           goto found;
+        if ( !list_empty(&heap[zone][i]) )
+            goto found;
 
     /* No suitable memory blocks. Fail the request. */
     spin_unlock(&heap_lock);
index d5384c4af5a39d0456be2212d56f1df0bcc35964..511df11a9e0f5ce44cee44fa753cd0840c905665 100644 (file)
@@ -1,3 +1,4 @@
+/* -*-  Mode:C; c-basic-offset:4; tab-width:4; indent-tabs-mode:nil -*- */
 
 #include <xen/lib.h>
 #include <xen/smp.h>
@@ -22,7 +23,7 @@
 static struct {
     char *name;
     enum { TYPE_SINGLE, TYPE_CPU, TYPE_ARRAY,
-          TYPE_S_SINGLE, TYPE_S_CPU, TYPE_S_ARRAY
+           TYPE_S_SINGLE, TYPE_S_CPU, TYPE_S_ARRAY
     } type;
     int nr_elements;
 } perfc_info[] = {
@@ -92,19 +93,19 @@ void perfc_reset(unsigned char key)
         switch ( perfc_info[i].type )
         {
         case TYPE_SINGLE:
-           atomic_set(&counters[0],0);
+            atomic_set(&counters[0],0);
         case TYPE_S_SINGLE:
             counters += 1;
             break;
         case TYPE_CPU:
             for ( j = sum = 0; j < smp_num_cpus; j++ )
-               atomic_set(&counters[j],0);
+                atomic_set(&counters[j],0);
         case TYPE_S_CPU:
             counters += NR_CPUS;
             break;
         case TYPE_ARRAY:
             for ( j = sum = 0; j < perfc_info[i].nr_elements; j++ )
-               atomic_set(&counters[j],0);
+                atomic_set(&counters[j],0);
         case TYPE_S_ARRAY:
             counters += perfc_info[i].nr_elements;
             break;
index f4d35e3c8bdcfdcbb3fd96d5a116f2ac3ced1fed..70181dfe50f49dbfcb4d80c8b737f00ecf8bfdcd 100644 (file)
@@ -1,4 +1,4 @@
-/* -*-  Mode:C; c-basic-offset:4; tab-width:4 -*-
+/* -*-  Mode:C; c-basic-offset:4; tab-width:4; indent-tabs-mode:nil -*-
  ****************************************************************************
  * (c) 2004 - Rolf Neugebauer - Intel Research Cambridge
  * (c) 2004 - Keir Fraser - University of Cambridge
@@ -150,9 +150,9 @@ int physdev_pci_access_modify(
 
     /* Make the domain privileged. */
     set_bit(DF_PHYSDEV, &p->d_flags);
-       /* FIXME: MAW for now make the domain REALLY privileged so that it
-        * can run a backend driver (hw access should work OK otherwise) */
-       set_bit(DF_PRIVILEGED, &p->d_flags);
+    /* FIXME: MAW for now make the domain REALLY privileged so that it
+     * can run a backend driver (hw access should work OK otherwise) */
+    set_bit(DF_PRIVILEGED, &p->d_flags);
 
     /* Grant write access to the specified device. */
     if ( (pdev = pci_find_slot(bus, PCI_DEVFN(dev, func))) == NULL )
index 0f479f068b4a2cf9926ecb2224dbd48216c92c24..7fff4059d953b80ba1e959cb02168e849fdc0a24 100644 (file)
@@ -1,3 +1,4 @@
+/* -*-  Mode:C; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- */
 /*
  *     linux/kernel/resource.c
  *
index ab84efa3ce8d40929c36578fd8f22c5f7d2ce4e9..73e008028149183311fca62cb1b67a08e2b5bff0 100644 (file)
@@ -1,3 +1,4 @@
+/* -*-  Mode:C; c-basic-offset:4; tab-width:4; indent-tabs-mode:nil -*- */
 /*
  * atropos.c
  * ---------
index f63dabcb5005fe99cede315dd6abd386c0c0c1f9..fb555781f1af812a01e6b3ba61acc978553432df 100644 (file)
@@ -1,4 +1,4 @@
-/* -*-  Mode:C; c-basic-offset:4; tab-width:4 -*-
+/* -*-  Mode:C; c-basic-offset:4; tab-width:4; indent-tabs-mode:nil -*-
  ****************************************************************************
  * (C) 2002-2003 - Rolf Neugebauer - Intel Research Cambridge
  * (C) 2002-2003 University of Cambridge
index 73d03bc787951dd13a52ddbbc9239490a43ad649..469fa007a25c732b29baee27e750995267f79d5d 100644 (file)
@@ -1,3 +1,4 @@
+/* -*-  Mode:C; c-basic-offset:4; tab-width:4; indent-tabs-mode:nil -*- */
 /****************************************************************************
  * Round Robin Scheduler for Xen
  *
index 21a1ae25acc392869d451ffb4de8e0b3b8e5804a..46176cf820ee3bd52aeaae730913128a2d947bb2 100644 (file)
@@ -1,4 +1,4 @@
-/* -*-  Mode:C; c-basic-offset:4; tab-width:4 -*-
+/* -*-  Mode:C; c-basic-offset:4; tab-width:4; indent-tabs-mode:nil -*-
  ****************************************************************************
  * (C) 2002-2003 - Rolf Neugebauer - Intel Research Cambridge
  * (C) 2002-2003 University of Cambridge
index 17e850b3f674550f1e3eefd66582026096f6cfac..dc635d1ab5c2ae351efc158bd65ea401c7c744ef 100644 (file)
@@ -1,3 +1,4 @@
+/* -*-  Mode:C; c-basic-offset:4; tab-width:4; indent-tabs-mode:nil -*- */
 /******************************************************************************
  * common/softirq.c
  * 
index 1f51b65ecb5432fdd1a22a9c31bf73421de6b741..c78652509a1dd6b00aabdd1b458d096bc9197ac2 100644 (file)
@@ -1,3 +1,4 @@
+/* -*-  Mode:C; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- */
 /*
  *  linux/lib/string.c
  *
index 83bf5ce55eed7449651c5ac9887bf24b24828ca6..0fcb8dbfd6c5ec1b009ddc4771f75fb9338392e7 100644 (file)
@@ -1,3 +1,4 @@
+/* -*-  Mode:C; c-basic-offset:4; tab-width:4; indent-tabs-mode:nil -*- */
 /******************************************************************************
  * common/trace.c
  *
index 906e7734db7235f13e5e60014c00498856972bee..d710d0bd72360bde132eab991ca7cf4b1eb6b929 100644 (file)
@@ -1,3 +1,4 @@
+/* -*-  Mode:C; c-basic-offset:4; tab-width:4; indent-tabs-mode:nil -*- */
 /*
  *  linux/lib/vsprintf.c
  *
@@ -115,13 +116,13 @@ static int skip_atoi(const char **s)
     return i;
 }
 
-#define ZEROPAD        1               /* pad with zero */
-#define SIGN   2               /* unsigned/signed long */
-#define PLUS   4               /* show plus */
-#define SPACE  8               /* space if plus */
-#define LEFT   16              /* left justified */
-#define SPECIAL        32              /* 0x */
-#define LARGE  64              /* use 'ABCDEF' instead of 'abcdef' */
+#define ZEROPAD 1               /* pad with zero */
+#define SIGN    2               /* unsigned/signed long */
+#define PLUS    4               /* show plus */
+#define SPACE   8               /* space if plus */
+#define LEFT    16              /* left justified */
+#define SPECIAL 32              /* 0x */
+#define LARGE   64              /* use 'ABCDEF' instead of 'abcdef' */
 
 static char * number(char * buf, char * end, long long num, int base, int size, int precision, int type)
 {
@@ -239,14 +240,14 @@ int vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
     char *str, *end, c;
     const char *s;
 
-    int flags;         /* flags to number() */
+    int flags;          /* flags to number() */
 
-    int field_width;   /* width of output field */
-    int precision;             /* min. # of digits for integers; max
-                                  number of chars for from string */
-    int qualifier;             /* 'h', 'l', or 'L' for integer fields */
-                               /* 'z' support added 23/7/1999 S.H.    */
-                               /* 'z' changed to 'Z' --davidm 1/25/99 */
+    int field_width;    /* width of output field */
+    int precision;              /* min. # of digits for integers; max
+                                   number of chars for from string */
+    int qualifier;              /* 'h', 'l', or 'L' for integer fields */
+                                /* 'z' support added 23/7/1999 S.H.    */
+                                /* 'z' changed to 'Z' --davidm 1/25/99 */
 
     str = buf;
     end = buf + size - 1;
@@ -267,7 +268,7 @@ int vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
         /* process flags */
         flags = 0;
     repeat:
-        ++fmt;         /* this also skips first '%' */
+        ++fmt;          /* this also skips first '%' */
         switch (*fmt) {
         case '-': flags |= LEFT; goto repeat;
         case '+': flags |= PLUS; goto repeat;
@@ -293,12 +294,12 @@ int vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
         /* get the precision */
         precision = -1;
         if (*fmt == '.') {
-            ++fmt;     
+            ++fmt;
             if (isdigit(*fmt))
                 precision = skip_atoi(&fmt);
             else if (*fmt == '*') {
                 ++fmt;
-                               /* it's the next argument */
+                          /* it's the next argument */
                 precision = va_arg(args, int);
             }
             if (precision < 0)
@@ -381,8 +382,8 @@ int vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
 
 
         case 'n':
-                               /* FIXME:
-                                 * What does C99 say about the overflow case here? */
+            /* FIXME:
+             * What does C99 say about the overflow case here? */
             if (qualifier == 'l') {
                 long * ip = va_arg(args, long *);
                 *ip = (str - buf);
@@ -401,7 +402,7 @@ int vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
             ++str;
             continue;
 
-                               /* integer number formats - set up the flags and "break" */
+                        /* integer number formats - set up the flags and "break" */
         case 'o':
             base = 8;
             break;
index 68c1db8345f680ecdb8951274e95e13d9e052f5d..8addc7e4d01780f33070cd7444ad95926ad05737 100644 (file)
@@ -1,4 +1,6 @@
-/* Simple allocator for Xen.  If larger than a page, simply use the
+/* -*-  Mode:C; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- */
+/******************************************************************************
+ * Simple allocator for Xen.  If larger than a page, simply use the
  * page-order allocator.
  *
  * Copyright (C) 2005 Rusty Russell IBM Corporation
@@ -17,6 +19,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
+
 #include <xen/mm.h>
 #include <xen/spinlock.h>
 #include <xen/ac_timer.h>
index 5494db499cc06bc0be58b426bc2fb8550e938169..009935efc0aed81c732de10dafa17f23f9eafd5a 100644 (file)
@@ -1,3 +1,4 @@
+/* -*-  Mode:C; c-basic-offset:4; tab-width:4; indent-tabs-mode:nil -*- */
 /******************************************************************************
  * console.c
  * 
index b085c7400ef68f9b4102986173e9a6fb28ab23e6..9ccad0ff4ae8ee1c2f3ed8c9acee8e99a4ce176d 100644 (file)
@@ -1,3 +1,4 @@
+/* -*-  Mode:C; c-basic-offset:4; tab-width:4; indent-tabs-mode:nil -*- */
 /******************************************************************************
  * serial.c
  * 
@@ -12,7 +13,6 @@
 #include <xen/init.h>
 #include <xen/irq.h>
 #include <xen/keyhandler.h> 
-#include <asm/pdb.h>
 #include <xen/reboot.h>
 #include <xen/sched.h>
 #include <xen/serial.h>
@@ -33,14 +33,14 @@ string_param("com2", opt_com2);
 #define MCR             0x04    /* Modem control        */
 #define LSR             0x05    /* line status          */
 #define MSR             0x06    /* Modem status         */
-#define DLL             0x00    /* divisor latch (ls) ( DLAB=1)        */
-#define DLM             0x01    /* divisor latch (ms) ( DLAB=1)        */
+#define DLL             0x00    /* divisor latch (ls) (DLAB=1) */
+#define DLM             0x01    /* divisor latch (ms) (DLAB=1) */
 
 /* Interrupt Enable Register */
 #define IER_ERDAI       0x01    /* rx data recv'd       */
 #define IER_ETHREI      0x02    /* tx reg. empty        */
 #define IER_ELSI        0x04    /* rx line status       */
-#define IER_EMSI        0x08    /* MODEM status                */
+#define IER_EMSI        0x08    /* MODEM status         */
 
 /* FIFO control register */
 #define FCR_ENABLE      0x01    /* enable FIFO          */
diff --git a/xen/include/asm-x86/pdb.h b/xen/include/asm-x86/pdb.h
deleted file mode 100644 (file)
index 79b0c41..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-
-/*
- * pervasive debugger
- * www.cl.cam.ac.uk/netos/pdb
- *
- * alex ho
- * 2004
- * university of cambridge computer laboratory
- */
-
-
-#ifndef __PDB_H__
-#define __PDB_H__
-
-#include <asm/regs.h>
-#include <xen/list.h>
-#include <public/dom0_ops.h>
-#include <public/xen.h>                   /* for domain id */
-
-extern int pdb_initialized;
-extern int pdb_com_port;
-extern int pdb_high_bit;
-extern int pdb_page_fault_possible;
-extern int pdb_page_fault_scratch;
-extern int pdb_page_fault;
-
-extern void initialize_pdb(void);
-
-/* Get/set values from generic debug interface. */
-extern int pdb_set_values(u_char *buffer, int length,
-                          unsigned long cr3, unsigned long addr);
-extern int pdb_get_values(u_char *buffer, int length,
-                          unsigned long cr3, unsigned long addr);
-
-/* External entry points. */
-extern int pdb_handle_exception(int exceptionVector,
-                               struct xen_regs *xen_regs);
-extern void pdb_do_debug(dom0_op_t *op);
-
-/* PDB Context. */
-struct pdb_context
-{
-    int valid;
-    int domain;
-    int process;
-    int system_call;              /* 0x01 break on enter, 0x02 break on exit */
-    unsigned long ptbr;
-};
-extern struct pdb_context pdb_ctx;
-
-/* Breakpoints. */
-struct pdb_breakpoint
-{
-    struct list_head list;
-    unsigned long address;
-    unsigned long cr3;
-    domid_t domain;
-};
-extern void pdb_bkpt_add (unsigned long cr3, unsigned long address);
-extern struct pdb_breakpoint* pdb_bkpt_search (unsigned long cr3, 
-                                              unsigned long address);
-extern int pdb_bkpt_remove (unsigned long cr3, unsigned long address);
-
-/* Conversions. */
-extern int   hex (char);
-extern char *mem2hex (char *, char *, int);
-extern char *hex2mem (char *, char *, int);
-extern int   hexToInt (char **ptr, int *intValue);
-
-/* Temporary Linux specific definitions */
-extern int pdb_system_call;
-extern unsigned char pdb_system_call_enter_instr;    /* original enter instr */
-extern unsigned char pdb_system_call_leave_instr;     /* original next instr */
-extern unsigned long pdb_system_call_next_addr;      /* instr after int 0x80 */
-extern unsigned long pdb_system_call_eflags_addr;   /* saved eflags on stack */
-
-unsigned long pdb_linux_pid_ptbr (unsigned long cr3, int pid);
-void pdb_linux_get_values(char *buffer, int length, unsigned long address,
-                         int pid, unsigned long cr3);
-void pdb_linux_set_values(char *buffer, int length, unsigned long address,
-                         int pid, unsigned long cr3);
-void pdb_linux_syscall_enter_bkpt (struct xen_regs *regs, long error_code,
-                                  trap_info_t *ti);
-void pdb_linux_syscall_exit_bkpt (struct xen_regs *regs, 
-                                 struct pdb_context *pdb_ctx);
-
-void pdb_handle_debug_trap(struct xen_regs *regs, long error_code);
-
-#endif  /* __PDB_H__ */
index f566be780933eb5b6e9e192267ba0af3673932c2..1fd7b23287907378fe757254e2c2f812e35d3bd9 100644 (file)
@@ -13,7 +13,6 @@
 #include <asm/cpufeature.h>
 #include <asm/desc.h>
 #include <asm/flushtlb.h>
-#include <asm/pdb.h>
 #include <xen/config.h>
 #include <xen/spinlock.h>
 #include <xen/cache.h>
@@ -453,16 +452,9 @@ extern idt_entry_t *idt_tables[];
     (memset(idt_tables[smp_processor_id()] + (_p)->fast_trap_idx, \
      0, 8))
 
-#ifdef XEN_DEBUGGER
-#define SET_FAST_TRAP(_p)   \
-    (pdb_initialized ? (void *) 0 : \
-       (memcpy(idt_tables[smp_processor_id()] + (_p)->fast_trap_idx, \
-               &((_p)->fast_trap_desc), 8)))
-#else
 #define SET_FAST_TRAP(_p)   \
     (memcpy(idt_tables[smp_processor_id()] + (_p)->fast_trap_idx, \
             &((_p)->fast_trap_desc), 8))
-#endif
 
 long set_fast_trap(struct exec_domain *p, int idx);
 
index 971f616286766f966caece0f8072a7b32ab4b84e..4557e5d08335fcd4691409850e66d52583a3095a 100644 (file)
@@ -19,7 +19,8 @@
 #ifndef __ASM_X86_VMX_PLATFORM_H__
 #define __ASM_X86_VMX_PLATFORM_H__
 
-#include <asm/e820.h>       /* from Linux */
+#include <public/xen.h>
+#include <asm/e820.h>
 
 #define MAX_OPERAND_NUM 3
 #define I_NAME_LEN  16